//
//  HJSQLDataTool.h
//  HJSQLDataTool_Example
//
//  Created by sky on 2019/11/22.
//  Copyright © 2019 hongjiang. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "FMDB/FMDB.h"


NS_ASSUME_NONNULL_BEGIN

@interface HJSQLDataTool : NSObject


+ (instancetype)sharedManager;

#pragma mark - 创建表
- (BOOL)createTableFromClass:(Class)objcClass;

- (BOOL)createTableWithTableName:(NSString *)tableName class:(Class)objcClass;

#pragma mark - 查询相关
///** 对象全属性判断数据是否已存在 */
//- (BOOL)isExistWithObject:(id)object;
///** 对象某个属性判断数据是否已存在 */
//- (BOOL)isExistWithTableName:(NSString *)tableName key:(NSString *)key value:(NSString *)value;

/** 查询某表中所有数据, 返回对象数组
 ** 注意:类名和表名必须一致
 */
- (NSArray *)getAllObjectsFromClass:(Class)objcClass;
/** 查询某表中所有数据, 根据类返回对象数组*/
- (NSArray *)getAllObjectsFromTableName:(NSString *)tableName objcClass:(Class)objcClass;
/** 根据条件查询某表中所有数据, 根据类返回对象数组
 **parament : 多个查询条件
 **sort : (sort 为空时不排序,  升序:ASC 降序:DESC)
 */
- (NSArray *)getAllObjectsFromTableName:(NSString *)tableName objcClass:(Class)objcClass parament:(NSDictionary *)parament sort:(NSString *)sort;
/** 返回表中某个属性所有值的数组*/
- (NSArray *)getAllValuesFromTableName:(NSString *)tableName WithKey:(NSString *)key;
#pragma mark - 更新相关
/** 更新表中所有匹配数据
 ** upParament 新值 value 的值都可以写成字符串
 ** matchParament 匹配的属性及值, 如果value是字符串需要加上 ''
 ** 字典中key 全部是字符串类型, 值,如果是
 */
- (BOOL)upDateWithTableName:(NSString *)tableName upParament:(NSDictionary *)upParament matchParament:(NSDictionary *)matchParament;

- (BOOL)insertTableWithObject:(id)object;

- (BOOL)insertWithTableName:(NSString *)tableName object:(id)object;

- (BOOL)insertTableWithObjects:(NSArray *)objects;

- (BOOL)insertWithTableName:(NSString *)tableName Objects:(NSArray *)objects;

#pragma mark - 删除相关
- (BOOL)deleteTableName:(NSString *)tableName;


- (BOOL)deleteDataFromeTable:(NSString *)tableName WithKey:(NSString *)key value:(NSString *)value;
/** 根据多个属性匹配删除一条数据 */
- (BOOL)deleteDataFromeTable:(NSString *)tableName WithParaments:(NSDictionary *)paraments;
#pragma mark - special
/** 对外暴露的fmdbQuen 如果遇到特殊业务不好封装时用 */
- (void)exposeWithBlk:(void (^)(FMDatabaseQueue * fmdbQuen))blk;


@end

NS_ASSUME_NONNULL_END
